package com.aigc.sclassroom.service.impl;

import com.aigc.sclassroom.mapper.ChatMessageMapper;
import com.aigc.sclassroom.pojo.ChatMessage;
import com.aigc.sclassroom.service.ChatMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ChatMessageServiceImpl implements ChatMessageService {

    @Autowired
    private ChatMessageMapper chatMessageMapper;

    @Override
    public ChatMessage saveChatMessage(ChatMessage chatMessage) {
        // 使用注入的实例调用方法
        chatMessageMapper.saveMessage(chatMessage);
        return chatMessage;
    }

    @Override
    public List<ChatMessage> getChatHistory(String sender, String receiver) {
        // 使用注入的实例调用方法
        return chatMessageMapper.findMessage(
                sender, receiver, receiver, sender);
    }

    @Override
    public List<ChatMessage> getGroupChatHistory(String sender, String receiver){

        return chatMessageMapper.findMessageById(sender, receiver);
    };

}
